﻿
@{
    ViewData["Title"] = "标识库存List";
}

@section Scripts
    {
    <link href="~/css/page.css" rel="stylesheet" />
    <script type="text/javascript">
        var selfLayer = null, page = 1, active = null;
        layui.use(['layer', 'table', 'laydate'], function () {
            var layer = layui.layer //弹层
                ,
                table = layui.table, form = layui.form; //表格
            layui.laydate.render({
                elem: '#RecordTime',
                type: 'month',
                range: true
            })

            //执行一个 table 实例
            table.render({
                id: 'dataList',
                elem: '#dataview',
                height: 'full-80',
                url: "/LogoStock/GetLogoInputStockAll",
               // headers: { 'Authorization': 'Bearer ' + localStorage.getItem("X-TOKEN") },
               // where: { status: "3" },
                request: {
                    pageName: 'index' //页码的参数名称，默认：page
                    , limitName: 'size' //每页数据量的参数名，默认：limit
                },
                parseData: function (res) { //res 即为原始返回的数据
                    console.log(res);
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.total, //解析数据长度
                        "data": res.result.data //解析数据列表
                    };
                },
                response: {
                    statusCode: 200 //规定成功的状态码，默认：0
                },
                done: function (res, curr, count) {
                    page = curr;
                },
                page: true,
                cols: [
                    [
                        { field: 'packageNo', title: '批量码', width: '10%' },
                        { field: 'qrCode', title: '标识二维码', width: '10%' },
                        { field: 'logoStockNo', title: '标识号', width: '10%' },
                        { field: 'type', title: '标识类型', width: '8%' },
                        { field: 'status', title: '状态', width: '10%',templet: function (d) {
                            if (d.status == 0) { return '未配发' }
                            else if (d.status == 1) { return '已配发' }                        
                            else if (d.status == 2) { return '已激活' }
                            } },
                        {
                            field: 'createTime', title: '导入时间', width: '10%',
                             templet : "<div>{{layui.util.toDateString(d.registeredTime, 'yyyy年MM月dd日')}}</div>"
                        }
                        //  { title: '状态', align: 'center', toolbar: '#remarks', width: '10%' },
                    ]
                ]
            });

            var $b = layui.$;
            active = {
                reload: function (page) {
                    //执行重载
                    table.reload('dataList', {
                        page: {
                            curr: page || 1 //重新从第 1 页开始
                        },
                        where: {
                            sasearch: $("#keyword").val(), 
                            status: $("#status").val(), 
                        }
                    });
                }
            };
            $b('#search').on('click', function () {
                var type = $b(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
            //监听工具条
            table.on('tool(datalist)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    ,
                    layEvent = obj.event; //获得 lay-event 对应的值
                //if (layEvent === 'edit') {
                //    window.location.href = "/SignageApplication/AllotmentEdit/?id=" + data.id + "&enId=" + data.enterpriseId + "&spId=" + data.speciesId;
                //} else if (layEvent == 'quiry') {
                //    window.location.href = "/SignageApplication/AllotmentQuire/" + data.id;
                //}
            });
        });
    </script>
}

<blockquote class="layui-elem-quote layui-text layui-form">
    <div class="layui-inline">
        <label class="layui-form-label">关键字：</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="keyword" name="keyword" style="width:210px" placeholder="">
        </div>
    </div>
    <div class="layui-inline">
        <label class="layui-form-label">状态：</label>
        <div class="layui-input-inline">
            <select id="status" name="dataType" lay-filter="dataType" autocomplete="off">
                <option value="">请选择状态</option>
                <option value="0">未配发</option>
                <option value="1">已配发</option>
                <option value="2">已激活</option>
            </select>
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-form-label">
            <button class="layui-btn" id="search" style="width: 60px; height: 28px; line-height: 28px; display: inline" data-type="reload">搜索</button>
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-form-label">
            <a class="layui-btn" style="width: 90px; height: 28px;line-height: 28px;" href="http://fishmanage.cnfm.com.cn:8101/Files/Excel/标签导入模板.xls">下载模板</a>
            @*<button class="layui-btn" id="excel" style="width: 90px; height: 28px; line-height: 28px; display: inline" data-type="reload">

                    下载模板
                </button>*@
        </div>
    </div>
    <div class="layui-inline">
        <div class="layui-form-block">
            <a asp-action="Add" class="layui-btn layui-btn-primary backIframe" style="width: 90px; height: 28px; line-height: 28px;">导入</a>
        </div>
    </div>
</blockquote>
<table class="layui-hide" id="dataview" lay-filter="datalist"></table>